<?php require_once('../Connections/learnConn.php'); 

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_learnConn, $learnConn);
$query = sprintf("SELECT * FROM pegawai");
//$query_siswaKelas = sprintf("SELECT * FROM siswa_kelas WHERE kd_kelas = %s ORDER BY nis ASC", GetSQLValueString($k, "string"));
$pegawai = mysql_query($query, $learnConn) or die(mysql_error());
$row_pegawai = mysql_fetch_assoc($pegawai);
 
#setting judul laporan dan header tabel
/*
if ($totalRows_nilai !=0) {
	$judul = "Hasil Untuk Nilai ".$_GET['nis']." Ditemukan Untuk Tahun Ajaran ".$_GET['ta']." Semester ".$_GET['smt'];
} else {
	$judul = "Hasil Untuk Nilai ".$_GET['nis']." Tidak Ditemukan Untuk Tahun Ajaran ".$_GET['ta'];
}
*/
$judul = 'Daftar Pegawai';
$header = array(
		array("label"=>"NIS", "length"=>80, "align"=>"L"),
		array("label"=>"Nama", "length"=>40, "align"=>"L"),
		array("label"=>"L/P", "length"=>30, "align"=>"L"),
		array("label"=>"TTL", "length"=>30, "align"=>"L")
	);	
#sertakan library FPDF dan bentuk objek
require_once ("fpdf/fpdf.php");
$pdf = new FPDF('p','mm','A4');
$pdf->AddPage(); 
#tampilkan judul laporan
$pdf->SetFont('Arial','','14');
$pdf->Cell(0,20, $judul, '0', 1, 'C'); 
#buat header tabel
$pdf->SetFont('Arial','','10');
$pdf->SetTextColor(0);
//$pdf->SetDrawColor(128,0,0);
//foreach ($header as $kolom) {
	//$pdf->Cell($kolom['length'], 5, $kolom['label'], 1, '0', $kolom['align'], true);
//}
$pdf->SetFillColor(222,222,222);
$pdf->Cell(10, 7, '', 0, '0', 'C', false);
$pdf->Cell(60, 7, 'Nama', 1, '0', 'C', true);
$pdf->Cell(10, 7, 'L/P', 1, '0', 'C', true);
$pdf->Cell(60, 7, 'TTL', 1, '0', 'C', true);
$pdf->Cell(40, 7, 'Jabatan', 1, '0', 'C', true);
$pdf->Cell(1, 7, '', 0, '0', 'C', false); //tambahan

$pdf->Ln();
#tampilkan data tabelnya
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0);
$pdf->SetFont('Arial','','10');
//$pdf->Ln();
//$pdf->Ln();
$rata = 0;
do{
	$pdf->Cell(10, 7, '', 0, '0', 'C', false);
	$pdf->Cell(60, 7, '   ' . $row_pegawai['nama'] , 1, '0', 'L', true);
	$pdf->Cell(10, 7, '   ' . $row_pegawai['jenis_kelamin'] , 1, '0', 'L', true);
	$pdf->Cell(60, 7, '   ' . $row_pegawai['tempat_lahir'] .', '. $row_pegawai['tanggal_lahir'], 1, '0', 'L', true);
	$pdf->Cell(40, 7, '   ' . $row_pegawai['jabatan'] , 1, '0', 'L', true);
	$pdf->Ln();
} while ($row_pegawai = mysql_fetch_assoc($pegawai));
	
	//$pdf->Cell(15,10,$total,0,0,'C');	
	//$pdf->Cell(20,10,$ratarata,0,0,'C');	
	//sy dah ada silincer nya, tinggal pipa na :D
	
/*
foreach ($data as $baris) {
	$i = 0;
	foreach ($baris as $cell) {
		$pdf->Cell($header[$i]['length'], 5, $cell, 1, '0', $kolom['align'], $fill);
		$i++;
	}
	$fill = !$fill;
	$pdf->Ln();
}
*/
#output file PDF
$pdf->Output();


?>
</body>
</html>